package main

import (
	"database/sql"
	_ "github.com/go-sql-driver/mysql"
	"fmt"
)

func main(){
	db,err := sql.Open("mysql","vagrant:vagrant@tcp(127.0.0.1:3306)/test?charset=utf8")
	if err != nil {
		panic(err)
		return
	}
	defer db.Close()

	// 增
	delete_sql := "delete from user where id = ? "
	stam,err := db.Prepare(delete_sql)
	if err != nil{
		fmt.Println("语句有误")
		return
	}
	result,err := stam.Exec(3)
	if err != nil {
		fmt.Println("没有执行成功")
		return
	}
	fmt.Println(result.RowsAffected())

}
